package com.seelyn.ddvideo.event;

import com.seelyn.ddvideo.model.Video;
import com.seelyn.ddvideo.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author ifcousing-linfeng
 * @since 2017/6/16
 */
@Component
public class ParseErrorListener implements ApplicationListener<ParseErrorEvent> {

    @Autowired
    private MailService mailService;

    @Override
    public void onApplicationEvent(ParseErrorEvent parseErrorEvent) {

        Video video = (Video) parseErrorEvent.getSource();
        String content = "解析网址错误：\n" + "来源网站：" + parseErrorEvent.getFromSite() +
                "\n视频类型：" + parseErrorEvent.getMovieType().name() +
                "\n页面类型：" + parseErrorEvent.getPageType().name() +
                "\n视频名称：" + video.getTitle();
        //mailService.sendMessageToAdministrator(content);

    }


}
